﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Admin.Shop.OrderMan
{
    public partial class OrderView : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IsLogin();
            if (!IsPostBack)
            {
                Bind();

            }
        }

        protected void Bind()
        {
            int shopID = Convert.ToInt32(Session["ShopID"]);
            string orderID = Request.QueryString["OrderID"];
            DataSet ds = new NS.BLL.Orders().GetShopOrderDetailByOrderID(orderID,shopID);
            DataTable dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {

                OrderState.SelectedValue = dt.Rows[0]["OrderState"].ToString();
                OrderID.Text = dt.Rows[0]["OrderID"].ToString();
                OrderTime.Text = dt.Rows[0]["OrderTime"].ToString();
                RealPrice.Text = dt.Rows[0]["RealPrice"].ToString();
                ShopName.Text = dt.Rows[0]["ShopName"].ToString();
                UserName.Text = dt.Rows[0]["UserName"].ToString();
                Phone.Text = dt.Rows[0]["Phone"].ToString();
                Address.Text = dt.Rows[0]["Address"].ToString();
                PostCode.Text = dt.Rows[0]["PostCode"].ToString();
                Remark.Text = dt.Rows[0]["Remark"].ToString();
            }

            OrderDetail.DataSource = ds.Tables[1];
            OrderDetail.DataBind();
        }

        protected void OrderState_SelectedIndexChanged(object sender, EventArgs e)
        {
            string orderID = OrderID.Text;
            int orderState = Convert.ToInt32(OrderState.SelectedValue);
            new NS.BLL.Orders().UpdateOrderState(orderID, orderState);

            Maticsoft.Common.MessageBox.Show(this, "订单状态修改成功");
        }
    }
}